package net.huashitong.ssydt.provider.money.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import net.huashitong.ssydt.PaginationResult;
import net.huashitong.ssydt.money.entity.SsMoneyGold;
import net.huashitong.ssydt.money.entity.vo.SsMoneyGoldQueryInVO;
import net.huashitong.ssydt.money.entity.vo.SsMoneyGoldRecordInVO;
import net.huashitong.ssydt.provider.money.service.SsMoneyGoldService;
import net.huashitong.ssydt.provider.web.model.Result;
import net.huashitong.ssydt.provider.web.utils.ResultUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @author hemj
 * @version 2017/8/21
 */
@Api(value = "/money/gold", tags = {"账户金币管理（后台）"})
@RestController
@RequestMapping("/money/gold")
public class SsMoneyGoldController {
	@Autowired
	private SsMoneyGoldService ssMoneyGoldService;

	@ApiOperation(value = "账户金币列表", notes = "账户金币列表")
	@GetMapping
	public Result<PaginationResult<SsMoneyGold>> paginationQuery(@ModelAttribute SsMoneyGoldQueryInVO ssMoneyGoldQueryInVO) {
		return ResultUtils.getSuccessResults(ssMoneyGoldService.paginationQuery(ssMoneyGoldQueryInVO));
	}

	@ApiOperation(value = "账户金币充值", notes = "账户金币充值")
	@PutMapping("/{userId}")
	public Result<String> updateGoldNumber(@PathVariable String userId, @Valid SsMoneyGoldRecordInVO ssMoneyGoldRecordInVO) {
		ssMoneyGoldRecordInVO.setUserId(userId);
		ssMoneyGoldService.updateGoldNumber(ssMoneyGoldRecordInVO);
		return ResultUtils.getSuccessResults();
	}
}
